package com.future.service.impl;

import com.future.mapper.UserMapper;
import com.future.pojo.Users;
import com.future.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    //引用类型自动注入@Autowired, @Resource
    @Autowired
    private UserMapper userMapper;
    //set方法
    public void setUserMapper(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    //添加用户
    @Override
    public int addUser(String userName,String userHao,String userPwd,String userEmail) {
        int nums = userMapper.insertUser(userName,userHao,userPwd,userEmail);
        return nums;
    }


    //检查账号
    @Override
    public Users checkHao(String userHao) {
        Users user= userMapper.checkHao(userHao);
        return user;
    }


    @Override
    public int checkUserHao(String userHao,String userLv){
        int num = userMapper.checkUserHao(userHao,userLv);
        return num;
    }

    //选择邮箱（修改密码）
    @Override
    public int changePwd(String userPwd, String userHao){
        int num = userMapper.changePwd(userPwd,userHao);
        return num;
    }

    //通过账号登录
    @Override
    public Users userHaoEnroll(String userHao){
        Users user = userMapper.userHaoLogin(userHao);
        return user;
    }
    //通过邮箱登录
    @Override
    public Users userEmailEnrrol(String userEmail) {
        Users user = userMapper.userEmailLogin(userEmail);
        return user;
    }
    //获取giteeId
    @Override
    public Users giteeLogin(String Id){
        Users user = userMapper.giteeLogin(Id);
        return user;
    }

    @Override
    public int checkEmail(String userEmail) {
        int num = userMapper.checkEmail(userEmail);
        return num;
    }

    //根据id查找用户个人信息
    @Override
    public List<Users> queryByIdUser(int userId) {
        return userMapper.queryByIdUser(userId);
    }


    //用户更新用户信息
    @Override
    public int updateuserUser(int userId, String userName, String userEmail, String userBirth,char userGen) {
        return userMapper.updateuserUser(userId, userName, userEmail,userBirth, userGen);
    }

    //注销账号
    @Override
    public int deleteMe(int userId) {
        return userMapper.deleteMe(userId);
    }

    //查询密码
    @Override
    public String queryMyPwd(int userId) {
        return userMapper.queryMyPwd(userId);
    }


    //申请成为歌手
    @Override
    public int changeSinger(int userId) {
        return userMapper.changeSinger(userId);
    }


    //判断是否添加到我喜欢
    @Override
    public int checkLike(String mcName, int userId) {
        int num = userMapper.checkLike(mcName,userId);
        return num;
    }

    @Override
    public int bindCount(String userHao, String Id) {
        int num = userMapper.bindCount(userHao,Id);
        return num;
    }
}
